package com.logistics.modules.vehicleManagement.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.logistics.modules.vehicleManagement.entity.VehicletypeEntity;
import com.logistics.modules.vehicleManagement.service.VehicletypeService;
import com.logistics.common.utils.PageUtils;
import com.logistics.common.utils.R;



/**
 * 
 *
 * @author HURRICANE
 * @email HURRICANE@nb.com
 * @date 2022-05-07 09:25:17
 */
@RestController
@RequestMapping("vehicleManagement/vehicletype")
public class VehicletypeController {
    @Autowired
    private VehicletypeService vehicletypeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("vehicleManagement:vehicletype:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = vehicletypeService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/listAll")
    @RequiresPermissions("vehicleManagement:vehicletype:list")
    public R listAll(){

        List<VehicletypeEntity> vehicleTypes =  vehicletypeService.selectAll();

        return R.ok().put("vehicleTypes", vehicleTypes);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("vehicleManagement:vehicletype:info")
    public R info(@PathVariable("id") Integer id){

		VehicletypeEntity vehicletype = vehicletypeService.getById(id);

        return R.ok().put("vehicletype", vehicletype);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("vehicleManagement:vehicletype:save")
    public R save(@RequestBody VehicletypeEntity vehicletype){

		vehicletypeService.save(vehicletype);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("vehicleManagement:vehicletype:update")
    public R update(@RequestBody VehicletypeEntity vehicletype){

		vehicletypeService.updateById(vehicletype);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("vehicleManagement:vehicletype:delete")
    public R delete(@RequestBody Integer[] ids){

		vehicletypeService.deleteByIds(Arrays.asList(ids));

        return R.ok();
    }

}
